package com.smit.common;

import com.smit.dvb.DVBFreqInfo;
import com.smit.dvb.DVBTunerInfo;

import java.io.Serializable;

/**
 * 频点表，搜索主频点用的
 */
public class FreqTable implements Serializable {
    private static final long serialVersionUID = 1L;

    private DVBFreqInfo[] tableForDTMB = {
            new DVBFreqInfo(1, 794000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DTMB), //shanxi dtmb 1
            new DVBFreqInfo(1, 802000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DTMB), //shanxi dtmb 1
            new DVBFreqInfo(1, 754000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DTMB) //shanxi dtmb 1
    };

    private DVBFreqInfo[] tableForDVBC = {
            new DVBFreqInfo(1, 459000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC), //wuhan mainfreq 1
            new DVBFreqInfo(2, 371000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC), //Jiangxi and Zhangjiajie mainfreq
            new DVBFreqInfo(3, 267000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC), //Anhui and Guangdongshengwang
            new DVBFreqInfo(4, 363000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC), //Chongqing mainfreq 1
            new DVBFreqInfo(5, 355000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC), //Tianjin mainfreq 1
            new DVBFreqInfo(6, 682000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC), //Shanxi xi'an mainfreq (allfreq)
            new DVBFreqInfo(7, 634000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC), //Henan mainfreq 2
            new DVBFreqInfo(8, 474000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC), //Qingdao mainfreq 1
            new DVBFreqInfo(9, 347000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC), //Qinghuangdao mainfreq 1
            new DVBFreqInfo(10, 403000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC), //Changzhou mainfreq 1
            new DVBFreqInfo(11, 762000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC), //Yancheng mainfreq 1
            new DVBFreqInfo(12, 506000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC), //Ningxia mainfreq (allfreq)
            new DVBFreqInfo(13, 498000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC), //YunnanChuxiong mainfreq2

            new DVBFreqInfo(14, 387000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC),
            new DVBFreqInfo(15, 395000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC),
            new DVBFreqInfo(16, 299000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC),
            new DVBFreqInfo(17, 379000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC),
            new DVBFreqInfo(18, 427000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC),
            new DVBFreqInfo(19, 259000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC),
            new DVBFreqInfo(20, 419000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC)

            /*new DVBFreqInfo(21, 307000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC),
            new DVBFreqInfo(22, 339000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC),
            new DVBFreqInfo(23, 243000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC),
            new DVBFreqInfo(24, 275000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC),
            new DVBFreqInfo(25, 283000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC),
            new DVBFreqInfo(26, 291000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC),
            new DVBFreqInfo(27, 459000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC),
            new DVBFreqInfo(28, 411000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC),
            new DVBFreqInfo(29, 451000, 6875, 64, 8, DVBTunerInfo.TUNER_TYPE_DVBC),*/
    };

    /**
     * 根据tunertype来获取频点表
     * @param tunerType tuner类型
     * @return 频点表
     */
    public DVBFreqInfo[] getFreqTable(int tunerType) {
        if ((tunerType & DVBTunerInfo.TUNER_TYPE_DTMB) != 0) {
            return tableForDTMB;
        } else if ((tunerType & DVBTunerInfo.TUNER_TYPE_DVBC) != 0) {
            return tableForDVBC;
        } else {
            return tableForDVBC;
        }
    }
}
